package com.shopping.control;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.shopping.entity.Manager;
import com.shopping.entity.Member;
import com.shopping.dao.impl.BizDaoImpl;
import com.shopping.service.impl.BizServiceImpl;

/**
 * Servlet implementation class DeleteServlet
 */
public class DeleteServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public DeleteServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see Servlet#init(ServletConfig)
	 */
	public void init(ServletConfig config) throws ServletException {
		// TODO Auto-generated method stub
	}

	/**
	 * @see Servlet#destroy()
	 */
	public void destroy() {
		// TODO Auto-generated method stub
	}

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	    doPost(request, response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	    BizDaoImpl bdi = new BizDaoImpl();
        BizServiceImpl bsi = new BizServiceImpl();
        bsi.setBizdao(bdi);
        String str=request.getParameter("sid");
        int id=Integer.valueOf(str);
        
        //System.out.println(id);
        int limm=bsi.getMenberById(id);
        //PrintWriter out= response.getWriter();
//        HttpSession session= request.getSession();
//        session.setAttribute("limm", limm);
//        System.out.println(limm);
        if(limm>0){
//            out.print("<script>");
//            out.print("alert('删除成功！');");
//            out.print("</script>");
            //out.flush();//刷新
            //out.close();
            //request.getRequestDispatcher("Member").forward(request, response);
            response.sendRedirect("Member");
        }

        
	}

}
